<template>
	<view class="container">
		<view class="body">
			<template v-for="(v,i) in userList" :key="i">
				<contactsVue :data="v"></contactsVue>
			</template>
		</view>
		<view class="footer">
			<view class="btn" @click="toAdduser" @delFun="delContact" @editFun="editContact">
				添加常用访客
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue';
	import {
		onShow
	} from "@dcloudio/uni-app"
	import {
		getMemInfo
	} from "@/api/user.js"
	import contactsVue from '../../components/contacts.vue';

	const userList = ref([])
	onShow(() => {
		getMemInfo().then(res => {
			userList.value = res.data
		})
	})


	// 点击去常用访客
	function toAdduser() {
		uni.navigateTo({
			url: '/pagesD/addcontacts/addcontacts'
		})
	}
	// 编辑
	function editContact(res) {
		console.log('编辑回传', res)
	}
	// 删除
	function delContact(res) {
		console.log('删除回传', res)
	}
</script>

<style lang="less" scoped>
	.container {
		display: flex;
		flex-direction: column;

		.body {
			flex: 1;
			padding: 0 20rpx;
			box-sizing: border-box;
		}

		.footer {
			width: 90%;
			margin-left: 5%;
			height: 120rpx;
			padding-bottom: 20rpx;
			box-sizing: border-box;

			.btn {
				background: orangered;
				color: #fff;
				line-height: 100rpx;
				text-align: center;
				border-radius: 100rpx;
			}
		}
	}
</style>